package cn.iocoder.yudao.module.pickbook.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.pickbook.dal.dataobject.user.PickbookUserDO;
import cn.iocoder.yudao.module.pickbook.service.user.PickbookUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "绘本用户 APP - 用户管理")
@RestController
@RequestMapping("/pickbook/app/user")
@Validated
@Slf4j
public class PickbookAppUserController {

    @Resource
    private PickbookUserService userService;

    @GetMapping("/test")
    @Operation(summary = "测试接口")
    public CommonResult<String> test() {
        return success("Pickbook module is working!");
    }

    @GetMapping("/info")
    @Operation(summary = "获取用户信息")
    public CommonResult<PickbookUserDO> getUserInfo(
            @RequestParam @Parameter(description = "用户ID") Long userId) {
        
        PickbookUserDO user = userService.getUser(userId);
        return success(user);
    }

    @PutMapping("/update")
    @Operation(summary = "更新用户信息")
    public CommonResult<Boolean> updateUserInfo(@RequestBody PickbookUserDO user) {
        userService.updateUser(user);
        return success(true);
    }

} 